home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 1.iso / toolbox / src / exampleCode / opengl / GLUT / test / test4.c < prev    next >
C/C++ Source or Header  |  1996-11-11  |  1KB  |  68 lines

  1.  
  2. /* Copyright (c) Mark J. Kilgard, 1994. */
  3.  
  4. /* This program is freely distributable without licensing fees 
  5.    and is provided without guarantee or warrantee expressed or 
  6.    implied. This program is -not- in the public domain. */
  7.  
  8. #ifdef __sgi
  9. #include <malloc.h>
  10. #endif
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <GL/glut.h>
  14. #include <glutint.h>
  15.  
  16. int ch = -2;
  17. void *font = GLUT_STROKE_ROMAN;
  18.  
  19. void
  20. tick(void)
  21. {
  22.   ch += 1;
  23.   if (ch > 180) {
  24.     if (font == GLUT_STROKE_MONO_ROMAN) {
  25.       printf("PASS: test4\n");
  26.       exit(0);
  27.     }
  28.     ch = -2;
  29.     font = GLUT_STROKE_MONO_ROMAN;
  30.   }
  31.   glutPostRedisplay();
  32. }
  33.  
  34. void
  35. display(void)
  36. {
  37.   glutIdleFunc(tick);
  38.   glClear(GL_COLOR_BUFFER_BIT);
  39.   glPushMatrix();
  40.   glutStrokeCharacter(font, ch);
  41.   glPopMatrix();
  42.   glutSwapBuffers();
  43. }
  44.  
  45. int
  46. main(int argc, char **argv)
  47. {
  48. #if defined(__sgi)  && !defined(REDWOOD)
  49.   /* XXX IRIX 6.0.1 mallopt(M_DEBUG, 1) busted. */
  50.   mallopt(M_DEBUG, 1);
  51. #endif
  52.   glutInit(&argc, argv);
  53.   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
  54.   glutInitWindowSize(200, 200);
  55.   glutCreateWindow("Test stroke fonts");
  56.   if (glutGet(GLUT_WINDOW_COLORMAP_SIZE) != 0) {
  57.     __glutFatalError("FAIL: bad RGBA colormap size");
  58.   }
  59.   glMatrixMode(GL_PROJECTION);
  60.   glLoadIdentity();
  61.   gluOrtho2D(-50, 150, -50, 150);
  62.   glClearColor(0.0, 0.0, 0.0, 1.0);
  63.   glColor3f(1.0, 1.0, 1.0);
  64.   glutDisplayFunc(display);
  65.   glutMainLoop();
  66.   return 0;             /* ANSI C requires main to return int. */
  67. }
  68.